﻿/* 采集程序 
 *
 * 正则匹配商品信息,弹出转发open
 *
 */
!function(){
var root = this;
//脚本加载
function loadJs(url, fnCallback, encode) {
    var script = document.createElement("SCRIPT"),
		head = document.getElementsByTagName("head")[0];
    script.language = "javascript";
    script.type = "text/javascript";
    script.src = url;
    if (encode != undefined)
        script.charset = encode;
    if (typeof fnCallback == 'function') {
        var argus;
        if (arguments.length > 3) {
            argus = Array.prototype.slice.call(arguments, 3)
        }
        if (document.all) {
            script.onreadystatechange = function () {
                if (script.readyState == "loaded" || script.readyState == 'complete') {
                    fnCallback(argus);
					head.removeChild(script);
                }
            }
        }
        else {
            script.onload = function () {
                fnCallback(argus);
				head.removeChild(script);
            }
        }
    }
    head.appendChild(script);
}

function load_jQuery(fn){
	if(root.$){
		if(fn){
			fn();
		}
	} else {
		loadJs("http://www.multishop.com:8080/multishop/assets/js/jquery-1.7.1.js",function(){
			if(fn){
				fn();
			}
		});
	}
}
//路由,字段配置
/* product = {
	title:"",//标题
	price:"",//价格
	priceImg:"",//img,京东等网站是图片价格
	img:"",//宝贝图片
	url:"",//宝贝链接
	sellNum:"",//最近销售量
	commentNum:"",//评论数
	shoptitle:"",
	shopurl:"",
	come:"",//来源,"淘宝,京东,拍拍等"
	user:"",//用户
	comment:""//评论
}
 */
//分享动作.1抓到,2弹出发送
root.fxbaobei = {
	loading:true,
	selector:{
		"tmall":{
			"urlReg":/detail.tmall.com\/item\.htm/i,
			"title":"#detail .tb-detail-hd h3 a",
			"price":"#J_StrPrice",
			"img":"#J_ImgBooth",
			"sellNum":"#detail .tb-sold-out em",
			"commentNum":"#J_MallReviewTabTrigger em",
			"shoptitle":"#shop-info .shop-title a",
			"shopurl":"#shop-info .shop-title a",
			"come":"tmall"
		}
	},
	init:function(){
		var self = this;
		load_jQuery(function(){
			self.loading = false;
			for(var i in self.selector.tmall){
				if(i!="urlReg"){
					console.log(i+":"+$(self.selector.tmall[i]).text());
				}
			}
		});
	},
	getType:function(){
	},
	getVal:function(){
	},
	postVal:function(){
	}
}
root.fxbaobei.init();
}();